﻿module CodeCamp02_Schedule
{
  import CodeCamp01.BasicTypes;
  import CodeCamp01.Events;
  import CodeCamp01.Contents;
    
  // types
  
  type Building
  {
    Id : Integer32 => AutoNumber();
    EventId : Event where value in Events;
    Name : Text128;
  }
  
  type Room
  {
    Id : Integer32 => AutoNumber();
    BuildingId : Building where value in Buildings;
    Name : Text128;
  }
  
  type Timeslot
  {
    Id : Integer32 => AutoNumber();
    EventId : Event where value in Events;
    Name : Text128;
    Date : Date;
    StartTime : Time;
    EndTime : Time;
  }
  
  type ScheduledSession
  {
    Id : Integer32 => AutoNumber();
    SessionId : Session where value in Sessions;
    TimeslotId : Timeslot where value in Timeslots;
    RoomId : Room where value in Rooms;
  }
  
  // extents
  
  Buildings : { Building* } where 
    identity Id,
    unique( EventId, Name );
  
  Rooms : { Room* } where 
    identity Id,
    unique( BuildingId, Name );
  
  Timeslots : { Timeslot* } where
    identity Id,
    unique( EventId, Date, StartTime, EndTime );
  
  ScheduledSessions : { ScheduledSession* } where
    identity Id,
    unique( TimeslotId, RoomId );
    
    // values
    
    Buildings
    {
      Franz { EventId => Events(1), Name => "Franz Hall" },
      Shiley { EventId => Events(1), Name => "Shiley Hall" },
      Buckley { EventId => Events(1), Name => "Buckley Center" }
    }
    
    Rooms
    {
        BAUD { BuildingId => Buildings.Buckley, Name => "Auditorium" },
        F005 { BuildingId => Buildings.Franz, Name => "Room 005" },
        F006 { BuildingId => Buildings.Franz, Name => "Room 006" },
        F015 { BuildingId => Buildings.Franz, Name => "Room 015" },
        F018 { BuildingId => Buildings.Franz, Name => "Room 018" },
        F025 { BuildingId => Buildings.Franz, Name => "Room 025" },
        F026 { BuildingId => Buildings.Franz, Name => "Room 026" },
        F034 { BuildingId => Buildings.Franz, Name => "Room 034" },
        F106 { BuildingId => Buildings.Franz, Name => "Room 106" },
        F108 { BuildingId => Buildings.Franz, Name => "Room 108" },
        F123 { BuildingId => Buildings.Franz, Name => "Room 123" },
        F128 { BuildingId => Buildings.Franz, Name => "Room 128" },
        F205 { BuildingId => Buildings.Franz, Name => "Room 205" },
        F217 { BuildingId => Buildings.Franz, Name => "Room 217" },
        F222 { BuildingId => Buildings.Franz, Name => "Room 222" },
        F223 { BuildingId => Buildings.Franz, Name => "Room 223" },
        F231 { BuildingId => Buildings.Franz, Name => "Room 231" },
        F234 { BuildingId => Buildings.Franz, Name => "Room 234" },
        S101 { BuildingId => Buildings.Shiley, Name => "Room 101" },
        S123 { BuildingId => Buildings.Shiley, Name => "Room 123" },
        S124 { BuildingId => Buildings.Shiley, Name => "Room 124" },
        S301 { BuildingId => Buildings.Shiley, Name => "Room 301" },
        S319 { BuildingId => Buildings.Shiley, Name => "Room 319" }
    }
    
    Timeslots
    {
      Session0x00  { EventId => Events(1), Name => "Session 0x00", Date => 2010-05-22, StartTime => 08:30:00, EndTime => 08:45:00 },
      Session0x01  { EventId => Events(1), Name => "Session 0x01", Date => 2010-05-22, StartTime => 09:00:00, EndTime => 10:15:00 },
      Session0x02  { EventId => Events(1), Name => "Session 0x02", Date => 2010-05-22, StartTime => 10:45:00, EndTime => 12:00:00 },
      Session0x03  { EventId => Events(1), Name => "Session 0x03", Date => 2010-05-22, StartTime => 12:15:00, EndTime => 13:15:00 },
      Session0x04  { EventId => Events(1), Name => "Session 0x04", Date => 2010-05-22, StartTime => 13:30:00, EndTime => 14:45:00 },
      Session0x05  { EventId => Events(1), Name => "Session 0x05", Date => 2010-05-22, StartTime => 15:15:00, EndTime => 16:30:00 },
      Session0x06  { EventId => Events(1), Name => "Session 0x06", Date => 2010-05-22, StartTime => 16:45:00, EndTime => 18:00:00 },
      Session0x07  { EventId => Events(1), Name => "Session 0x07", Date => 2010-05-22, StartTime => 19:30:00, EndTime => 22:00:00 }
    }
}
